package com.lizemin.controller;

import com.lizemin.entity.User;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lzm
 * @date 2025/5/16 21:49
 * @description
 */
public class UserControllerImpl implements Controller {

    @Override
    public List<User> getAllUsers() {
        return queryUsers();
    }

    @Override
    public User getUserById(Integer id) {
        return getUser(id);
    }

    private static ArrayList<User> queryUsers() {
        int id;
        ArrayList<User> users = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            id = i + 1;
            User user = new User();
            user.setId(id);
            user.setName("csdn—" + id);
            user.setAge(20 + i);
            users.add(user);
        }
        return users;
    }

    private static User getUser(Integer id) {
        User user = new User();
        user.setId(id);
        user.setName("csdn");
        user.setAge(20);
        return user;
    }

}
